//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//    Crolengi, this program (a part of program) is gameengine based on C++\Directx
//    Copyright (C) 2008 Pashinin Anton Alekseevich (Crol)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//    (INCLUDING NEGLIGENCE OR OTHERWISE) 
//    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
//    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//    Contacts: 
//    Mail: crolengi@gmail.com
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#ifndef  DrawingFunctions_h
#define  DrawingFunctions_h

#include <d3d9.h>
#include <d3dx9.h>

struct DrawingLines{
	float x,y,z;
	D3DXCOLOR color;
	};

void drawLine(D3DXVECTOR3 a,D3DXVECTOR3 b,LPDIRECT3DDEVICE9 *Device)
{

	DrawingLines verticles[2] = {a.x,a.y,a.z,D3DCOLOR_XRGB(256,0,0),
		                         b.x,b.y,b.z,D3DCOLOR_XRGB(0,0,256)};	

	(*Device)->DrawPrimitiveUP(D3DPT_LINELIST,1,verticles,sizeof(verticles[0]));

}

void drawBox(D3DXVECTOR3 a,D3DXVECTOR3 b,LPDIRECT3DDEVICE9 *Device)
{
                                 //1
DrawingLines verticles[24]  ={   a.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
		                         b.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 a.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),

                                 //2
								 a.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
		                         a.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 a.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 a.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 //3
								 b.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 //4
								 b.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 //5
								 b.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 };	

	(*Device)->DrawPrimitiveUP(D3DPT_LINELIST,12,verticles,sizeof(verticles[0]));

}

void drawBox(D3DXVECTOR3 m,unsigned int n,LPDIRECT3DDEVICE9 *Device)
{

	D3DXVECTOR3 a,b;
	a.x = m.x - n;
	a.y = m.y - n;
	a.z = m.z - n;

	a.x = m.x + n;
	a.y = m.y + n;
	a.z = m.z + n;
                                 //1
DrawingLines verticles[24]  ={   a.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
		                         b.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 a.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),

                                 //2
								 a.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
		                         a.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 a.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 a.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),

								 //3
								 b.x,a.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 //4
								 b.x,b.y,a.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 b.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 a.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 //5
								 b.x,a.y,b.z,D3DCOLOR_XRGB(255,255,255),
								 b.x,b.y,b.z,D3DCOLOR_XRGB(255,255,255),

								 };	

	(*Device)->DrawPrimitiveUP(D3DPT_LINELIST,12,verticles,sizeof(verticles[0]));

}

#endif 